package cn.usian.basicInformation.sensitivewords.config;


import cn.usian.basicInformation.sensitivewords.mapper.SensitiveWordsMapper;
import cn.usian.pojo.basicInformation.sensitivewords.BaseSensitiveWords;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;


import java.util.List;
 
/**
 * 初始化敏感关键字
 * @author wuKeFan
 * @date 2023-03-02 13:57:45
 */
@Component
public class StartInit {
 
    @Resource
    private SensitiveWordsMapper sensitiveWordMapper;
 
    @PostConstruct
    public void init() {
        // 从数据库中获取敏感词对象集合（调用的方法来自Dao层，此方法是service层的实现类）
        List<BaseSensitiveWords> sensitiveWords = sensitiveWordMapper.selectList(new QueryWrapper<>());
        // 构建敏感词库
        SensitiveWordUtils.initKeyWord(sensitiveWords);
    }
 
}